package org.jobtask.schedule;

import java.io.Serializable;
import java.text.SimpleDateFormat;


/**
 * 
 * @author Bob Coyote
 *描述: 一个标识键值对的对象
 */
public class KeyValue  implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7946615238781368041L;
	private Object key=null;
	private Object value=null;
	
	public KeyValue(){
	}
	
	public KeyValue(String k,String v){
		this.key=k;
		this.value=v;
	}
	
	public KeyValue(Object k,Object v){
		this.key=k;
		this.value=v;
	}
	
	public Object getKey() {
		return key;
	}
	public void setKey(Object key) {
		this.key = key;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	
	@Override
	public String toString(){
		String k="";
		if(key instanceof java.util.Date){
			SimpleDateFormat sdf=new  SimpleDateFormat("HH:mm:ss");
			k="  -- / -- / --  "+sdf.format((java.util.Date)key)+"                       ";
		}else{
			k="";
		}
		return k+this.value.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((key == null) ? 0 : key.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		KeyValue other = (KeyValue) obj;
		if (key == null) {
			if (other.key != null)
				return false;
		} else if (!key.equals(other.key))
			return false;
		return true;
	}

	
	
	
}
